package com.xdcplus.web.controller.bd;



import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.bd.BdWetWeightAlarmConfigDTO;
import com.xdcplus.web.common.pojo.dto.bd.BdWetWeightAlarmConfigFilterDTO;
import com.xdcplus.web.common.pojo.vo.bd.BdWetWeightAlarmConfigVO;
import com.xdcplus.web.service.bd.BdWetWeightAlarmConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * 丝印湿重报警推送配置(BdWetWeightAlarmConfig)表服务控制层
 *
 * @author Zhecheng.Ren
 * @since 2024-10-22 15:10:15
 */
@Api(tags = "丝印湿重报警推送配置(BdWetWeightAlarmConfig)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("bdWetWeightAlarmConfig")
public class BdWetWeightAlarmConfigController extends AbstractController {

    @Resource
    private BdWetWeightAlarmConfigService bdWetWeightAlarmConfigService;

    @ApiOperation("新增丝印湿重报警推送配置")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<Void> saveBdWetWeightAlarmConfig(@RequestBody BdWetWeightAlarmConfigDTO bdWetWeightAlarmConfigDTO) {

        log.info("saveBdWetWeightAlarmConfig {}", bdWetWeightAlarmConfigDTO.toString());

        bdWetWeightAlarmConfigDTO.setCreatedUser(getAccount());
        bdWetWeightAlarmConfigService.saveBdWetWeightAlarmConfig(bdWetWeightAlarmConfigDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改丝印湿重报警推送配置")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<Void> updateBdWetWeightAlarmConfig(@RequestBody BdWetWeightAlarmConfigDTO bdWetWeightAlarmConfigDTO) {

        log.info("updateBdWetWeightAlarmConfig {}", bdWetWeightAlarmConfigDTO.toString());

        bdWetWeightAlarmConfigDTO.setUpdatedUser(getAccount());
        bdWetWeightAlarmConfigService.updateBdWetWeightAlarmConfig(bdWetWeightAlarmConfigDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除丝印湿重报警推送配置")
    @DeleteMapping(value = "/{bdWetWeightAlarmConfigId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "bdWetWeightAlarmConfigId", dataTypeClass = Long.class, value = "丝印湿重报警推送配置ID", required = true),
    })
    public ResponseVO<Void> deleteBdWetWeightAlarmConfigLogical(@PathVariable("bdWetWeightAlarmConfigId")
                                         @NotNull(message = "丝印湿重报警推送配置ID不能为空") Long bdWetWeightAlarmConfigId) {

        log.info("deleteBdWetWeightAlarmConfigLogical {}", bdWetWeightAlarmConfigId);

        bdWetWeightAlarmConfigService.deleteBdWetWeightAlarmConfigLogical(bdWetWeightAlarmConfigId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除丝印湿重报警推送配置")
    @DeleteMapping(value = "/deleteByIds/{bdWetWeightAlarmConfigIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "bdWetWeightAlarmConfigId", dataTypeClass = Long.class, value = "丝印湿重报警推送配置ID", required = true),
    })
    public ResponseVO<Void> deleteBdWetWeightAlarmConfigLogical(@PathVariable("bdWetWeightAlarmConfigIds")
                                         @NotNull(message = "丝印湿重报警推送配置ID不能为空") String bdWetWeightAlarmConfigIds) {

        log.info("deleteBdWetWeightAlarmConfigByIds {}", bdWetWeightAlarmConfigIds);

        bdWetWeightAlarmConfigService.deleteBdWetWeightAlarmConfigByIds(bdWetWeightAlarmConfigIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询丝印湿重报警推送配置")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<BdWetWeightAlarmConfigVO>> findBdWetWeightAlarmConfig(BdWetWeightAlarmConfigFilterDTO bdWetWeightAlarmConfigFilterDTO) {

        log.info("findBdWetWeightAlarmConfig {}", bdWetWeightAlarmConfigFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(bdWetWeightAlarmConfigFilterDTO);

        return ResponseVO.success(bdWetWeightAlarmConfigService.queryBdWetWeightAlarmConfig(bdWetWeightAlarmConfigFilterDTO));
    }


}
